package ycl.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ycl.base.req.SysMenuReq;
import ycl.common.ApiResult;
import ycl.common.base.controller.BaseController;
import ycl.common.models.base.A;
import ycl.system.entity.SysMenu;
import ycl.system.res.SysMenuRes;
import ycl.system.service.SysMenuService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * <p>
 * 菜单 前端控制器
 * </p>
 *
 * @author ycl
 * @since 2022-03-03 11:43:56
 */
@RestController
@RequestMapping("/sys-menu")
@Api(tags = "菜单")
public class SysMenuController extends BaseController<SysMenu, SysMenuReq, SysMenuRes> {

	@Resource
	private SysMenuService sysMenuService;

	@Override
	public ApiResult<Page<SysMenuRes>> pageList(SysMenu sysMenu) {
		return ApiResult.success(sysMenuService.pageList(sysMenu, SysMenuRes.class));
	}

	@Override
	public <E extends SysMenuReq> ApiResult<A> save(HttpServletRequest request, @Valid E e) {
		sysMenuService.save(request, e, SysMenu.class);
		return ApiResult.success();
	}

	@Override
	public <E extends SysMenuReq> ApiResult<A> update(HttpServletRequest request, @Valid E e) {
		sysMenuService.update(request, e, SysMenu.class);
		return ApiResult.success();
	}
}
